home *** CD-ROM | disk | FTP | other *** search
Wrap
VERSION 5.00 Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX" Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX" Begin VB.Form RichText BackColor = &H80000005& Caption = "Form1" ClientHeight = 8460 ClientLeft = -870 ClientTop = 2130 ClientWidth = 11190 FillColor = &H000000FF& LinkTopic = "Form1" MDIChild = -1 'True ScaleHeight = 8460 ScaleWidth = 11190 WindowState = 2 'Maximized Begin ComctlLib.Toolbar bar Align = 1 'Align Top Height = 420 Left = 0 Negotiate = -1 'True TabIndex = 1 Tag = "noprint" Top = 0 Width = 11190 _ExtentX = 19738 _ExtentY = 741 ButtonWidth = 609 ButtonHeight = 582 AllowCustomize = 0 'False Wrappable = 0 'False Appearance = 1 ImageList = "ImageList1" _Version = 327682 BeginProperty Buttons {0713E452-850A-101B-AFC0-4210102A8DA7} NumButtons = 23 BeginProperty Button1 {0713F354-850A-101B-AFC0-4210102A8DA7} Object.ToolTipText = "Print" Object.Tag = "" ImageIndex = 1 Object.Width = 35 EndProperty BeginProperty Button2 {0713F354-850A-101B-AFC0-4210102A8DA7} Object.ToolTipText = "Preview" Object.Tag = "" ImageIndex = 15 EndProperty BeginProperty Button3 {0713F354-850A-101B-AFC0-4210102A8DA7} Object.ToolTipText = "Open File" Object.Tag = "" ImageIndex = 3 EndProperty BeginProperty Button4 {0713F354-850A-101B-AFC0-4210102A8DA7} Object.ToolTipText = "New" Object.Tag = "" ImageIndex = 14 EndProperty BeginProperty Button5 {0713F354-850A-101B-AFC0-4210102A8DA7} Object.ToolTipText = "Save" Object.Tag = "" ImageIndex = 2 EndProperty BeginProperty Button6 {0713F354-850A-101B-AFC0-4210102A8DA7} Object.ToolTipText = "Font Color" Object.Tag = "" ImageIndex = 17 EndProperty BeginProperty Button7 {0713F354-850A-101B-AFC0-4210102A8DA7} Object.ToolTipText = "Bold" Object.Tag = "" ImageIndex = 4 EndProperty BeginProperty Button8 {0713F354-850A-101B-AFC0-4210102A8DA7} Object.ToolTipText = "Underline" Object.Tag = "" ImageIndex = 6 EndProperty BeginProperty Button9 {0713F354-850A-101B-AFC0-4210102A8DA7} Object.ToolTipText = "Italic" Object.Tag = "" ImageIndex = 5 EndProperty BeginProperty Button10 {0713F354-850A-101B-AFC0-4210102A8DA7} Object.ToolTipText = "Undo" Object.Tag = "" ImageIndex = 18 EndProperty BeginProperty Button11 {0713F354-850A-101B-AFC0-4210102A8DA7} Object.Tag = "" Style = 4 Object.Width = 30 MixedState = -1 'True EndProperty BeginProperty Button12 {0713F354-850A-101B-AFC0-4210102A8DA7} Object.ToolTipText = "Align Left" Object.Tag = "" ImageIndex = 7 EndProperty BeginProperty Button13 {0713F354-850A-101B-AFC0-4210102A8DA7} Object.ToolTipText = "Center" Object.Tag = "" ImageIndex = 8 EndProperty BeginProperty Button14 {0713F354-850A-101B-AFC0-4210102A8DA7} Object.ToolTipText = "Align Right" Object.Tag = "" ImageIndex = 9 EndProperty BeginProperty Button15 {0713F354-850A-101B-AFC0-4210102A8DA7} Object.Tag = "" Style = 4 Object.Width = 30 MixedState = -1 'True EndProperty BeginProperty Button16 {0713F354-850A-101B-AFC0-4210102A8DA7} Object.ToolTipText = "Copy" Object.Tag = "" ImageIndex = 12 EndProperty BeginProperty Button17 {0713F354-850A-101B-AFC0-4210102A8DA7} Object.ToolTipText = "Cut" Object.Tag = "" ImageIndex = 11 EndProperty BeginProperty Button18 {0713F354-850A-101B-AFC0-4210102A8DA7} Object.ToolTipText = "Paste" Object.Tag = "" ImageIndex = 13 EndProperty BeginProperty Button19 {0713F354-850A-101B-AFC0-4210102A8DA7} Object.ToolTipText = "Search" Object.Tag = "" ImageIndex = 10 EndProperty BeginProperty Button20 {0713F354-850A-101B-AFC0-4210102A8DA7} Object.ToolTipText = "Close" Object.Tag = "" ImageIndex = 16 EndProperty BeginProperty Button21 {0713F354-850A-101B-AFC0-4210102A8DA7} Object.Tag = "" Style = 4 Object.Width = 2445 MixedState = -1 'True EndProperty BeginProperty Button22 {0713F354-850A-101B-AFC0-4210102A8DA7} Object.Tag = "" Style = 3 MixedState = -1 'True EndProperty BeginProperty Button23 {0713F354-850A-101B-AFC0-4210102A8DA7} Object.Tag = "" Style = 4 Object.Width = 1000 MixedState = -1 'True EndProperty EndProperty BorderStyle = 1 Begin VB.ComboBox FontNames Height = 315 Left = 6330 Sorted = -1 'True TabIndex = 3 Top = 30 Width = 2340 End Begin VB.ComboBox FontSizes Height = 315 Left = 8730 Style = 2 'Dropdown List TabIndex = 2 Top = 15 Width = 915 End End Begin RichTextLib.RichTextBox Rich Height = 6720 Left = 915 TabIndex = 0 Top = 735 Width = 8730 _ExtentX = 15399 _ExtentY = 11853 _Version = 393217 BackColor = 16777215 BorderStyle = 0 ScrollBars = 2 DisableNoScroll = -1 'True BulletIndent = 100 Appearance = 0 RightMargin = 7000 TextRTF = $"Rtf.frx":0000 End Begin ComctlLib.ImageList ImageList1 Left = 540 Top = 7635 _ExtentX = 1005 _ExtentY = 1005 BackColor = -2147483643 ImageWidth = 16 ImageHeight = 16 MaskColor = 12632256 _Version = 327682 BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7} NumListImages = 18 BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "Rtf.frx":00FD Key = "" EndProperty BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "Rtf.frx":020F Key = "" EndProperty BeginProperty ListImage3 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "Rtf.frx":0321 Key = "" EndProperty BeginProperty ListImage4 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "Rtf.frx":0433 Key = "" EndProperty BeginProperty ListImage5 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "Rtf.frx":0545 Key = "" EndProperty BeginProperty ListImage6 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "Rtf.frx":0657 Key = "" EndProperty BeginProperty ListImage7 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "Rtf.frx":0769 Key = "" EndProperty BeginProperty ListImage8 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "Rtf.frx":087B Key = "" EndProperty BeginProperty ListImage9 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "Rtf.frx":098D Key = "" EndProperty BeginProperty ListImage10 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "Rtf.frx":0A9F Key = "" EndProperty BeginProperty ListImage11 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "Rtf.frx":0BB1 Key = "" EndProperty BeginProperty ListImage12 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "Rtf.frx":0CC3 Key = "" EndProperty BeginProperty ListImage13 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "Rtf.frx":0DD5 Key = "" EndProperty BeginProperty ListImage14 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "Rtf.frx":0EE7 Key = "" EndProperty BeginProperty ListImage15 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "Rtf.frx":1429 Key = "" EndProperty BeginProperty ListImage16 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "Rtf.frx":196B Key = "" EndProperty BeginProperty ListImage17 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "Rtf.frx":1C85 Key = "" EndProperty BeginProperty ListImage18 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "Rtf.frx":1F9F Key = "" EndProperty EndProperty End Attribute VB_Name = "RichText" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Dim SearchStr As String Const EM_UNDO = &HC7 Private Type CHOOSECOLOR lStructSize As Long hWndOwner As Long hInstance As Long rgbResult As Long lpCustColors As String Flags As Long lCustData As Long lpfnHook As Long lpTemplateName As String End Type Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (ofn As OPENFILENAME) As Boolean Private Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (ofn As OPENFILENAME) As Boolean Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Type OPENFILENAME lStructSize As Long hWndOwner As Long hInstance As Long strFilter As String strCustomFilter As String nMaxCustFilter As Long NFilterIndex As Long strFile As String nMaxFile As Long strFileTitle As String nMaxFileTitle As Long strInitialDir As String strTitle As String Flags As Long nFileOffset As Integer nFileExtension As Integer strDefExt As String lCustData As Long lpfnHook As Long lpTemplateName As String End Type Const EM_GETMODIFY = &HB8 Const EM_SETMODIFY = &HB9 Const OFN_READONLY = &H1 Const OFN_OVERWRITEPROMPT = &H2 Const OFN_HIDEREADONLY = &H4 Const OFN_NOCHANGEDIR = &H8 Const OFN_SHOWHELP = &H10 Const OFN_NOVALIDATE = &H100 Const OFN_ALLOWMULTISELECT = &H200 Const OFN_EXTENSIONDIFFERENT = &H400 Const OFN_PATHMUSTEXIST = &H800 Const OFN_FILEMUSTEXIST = &H1000 Const OFN_CREATEPROMPT = &H2000 Const OFN_SHAREAWARE = &H4000 Const OFN_NOREADONLYRETURN = &H8000 Const OFN_NOTESTFILECREATE = &H10000 Const OFN_NONETWORKBUTTON = &H20000 Const OFN_NOLONGNAMES = &H40000 Const OFN_EXPLORER = &H80000 Const OFN_NODEREFERENCELINKS = &H100000 Const OFN_LONGNAMES = &H200000 Dim UndoRich As RichTextBox Dim Changed As Boolean Dim RPFileName As String Private Declare Function ChooseColorAPI Lib "comdlg32.dll" Alias "ChooseColorA" (pChoosecolor As CHOOSECOLOR) As Long Private Function RoboFileOpen(FrHd As Long, _ Optional ByVal OpenDialog, _ Optional ByRef Flags, _ Optional ByVal InitDir, _ Optional ByVal FileName, _ Optional ByVal BoxTitle, _ Optional ByVal Filters, _ Optional ByVal DefaultFilter, _ Optional ByVal DefaultExt _ ) As Integer ' OpenDialog: False = Open, True = Save ' Flags: Standard api flag constants. (modified by reference) Dim dlg As OPENFILENAME Dim ret As Boolean Dim n As Integer Dim Ieshno As String, StringFile As String, Est As String On Error Resume Next Const BufferLen As Integer = 512 If IsMissing(Flags) Then Flags = sjmOFN_HIDEREADONLY If IsMissing(InitDir) Then InitDir = CurDir If IsMissing(FileName) Then FileName = "" If Not OpenDialog Then BoxTitle = "Open -" Else BoxTitle = "Save -" BoxTitle = BoxTitle + "Roboprint " + RPFileName If IsMissing(Filters) Then Filters = "Text Files (*.txt)|*.txt|RichText Files (*.rtf)|*.rtf" ' "Rtf Files (*.rtf);Text Files (*.txt)" If IsMissing(DefaultFilter) Then DefaultFilter = 2 If IsMissing(DefaultExt) Then DefaultExt = "" For n = 1 To Len(Filters) If Mid$(Filters, n, 1) = "|" Then Mid$(Filters, n) = vbNullChar Next With dlg .lStructSize = Len(dlg) .hWndOwner = FrHd .strFilter = Filters .NFilterIndex = DefaultFilter .strFile = RPFileName .nMaxFile = BufferLen .strTitle = BoxTitle .Flags = Flags .strDefExt = DefaultExt .strInitialDir = InitDir .nMaxCustFilter = BufferLen .strCustomFilter = String$(BufferLen, vbNullChar) .strFile = RPFileName + String$(40, vbNullChar) End With RoboFileOpen = 1 If OpenDialog Then ret = GetSaveFileName(dlg) Else ret = GetOpenFileName(dlg) End If Ieshno = dlg.strCustomFilter If ret Then i = InStr(1, dlg.strFile, Chr$(0), vbTextCompare) StringFile = Left(dlg.strFile, Len(dlg.strFile)) StringFile = Trim(StringFile) i = InStr(1, dlg.strFile, ".", vbTextCompare) Ieshno = Left(StringFile, i - 1) StringFile = Left(StringFile, Len(Ieshno) + 4) StringFile = Right(StringFile, 3) If StringFile <> "txt" And StringFile <> "rtf" Then n = MsgBox(StringFile + " is a invalid extension", vbAbortRetryIgnore, "File Name Error") RoboFileOpen = n Exit Function End If RoboFileOpen = 1 Ieshno = Ieshno + "." + StringFile Ieshno = Dir(Ieshno) If Ieshno <> "" Then If OpenDialog Then Rich.SaveFile Ieshno RPFileName = Ieshno Else Rich.LoadFile Ieshno RPFileName = Ieshno End If Rich.Refresh Exit Function End If RoboFileOpen = 1 End If End Function Private Function ShowColorDialog() As Long Dim cc As CHOOSECOLOR Dim Custcolor(16) As Long Dim lReturn As Long Dim CustomColors(0 To 63) As Byte For i = 0 To 63 CustomColors(i) = 128 Select Case j Case 0 CustomColors(i) = 255 'red, 0 to 255 Case 1 CustomColors(i) = 255 'green, 0 to 255 Case 2 CustomColors(i) = 128 'blue, 0 to 255 Case 3 CustomColors(i) = 0 'intensity, 0 to 1 j = -1 End Select j = j + 1 cc.lStructSize = Len(cc) cc.hWndOwner = Me.hwnd cc.hInstance = 0 cc.lpCustColors = StrConv(CustomColors, vbUnicode) cc.Flags = 0 lReturn = ChooseColorAPI(cc) If lReturn <> 0 Then ShowColorDialog = cc.rgbResult 'return the color ShowColorDialog = -1 End If End Function Private Sub bar_ButtonClick(ByVal Button As ComctlLib.Button) Dim tempColor As Long Dim Res As Integer Select Case Button.Index Case 1 SampleMdi.Roboprint1.LVPrint Case 2 SampleMdi.Roboprint1.Preview Case 3 Changed = SendMessage(Rich.hwnd, EM_GETMODIFY, 0, 0) If Changed Then Res = MsgBox("Save Change to the file " + RPFileName, vbYesNoCancel, "Roboprint") If Res = 2 Then Exit Sub If Res = 6 Then Res = 4 Do While Res = 4 Res = RoboFileOpen(Me.hwnd, True) If Res = 3 Then Exit Sub End If End If RoboFileOpen Me.hwnd, False SendMessage Rich.hwnd, EM_SETMODIFY, False, 0 Case 4 Changed = SendMessage(Rich.hwnd, EM_GETMODIFY, 0, 0) If Not Changed Then Rich.TextRTF = "" Res = 4 Do While Res = 4 Res = RoboFileOpen(Me.hwnd, True) If Res = 3 Then Exit Sub End If Rich.TextRTF = "" SendMessage Rich.hwnd, EM_SETMODIFY, False, 0 Case 5 RoboFileOpen Me.hwnd, True SendMessage Rich.hwnd, EM_SETMODIFY, False, 0 Case 6 tempColor = ShowColorDialog() Rich.SelColor = tempColor If tempColor < 0 Then Exit Sub Case 8 Rich.SelUnderline = Not Rich.SelUnderline bar.Buttons(8).MixedState = Rich.SelUnderline Case 9 Rich.SelItalic = Not Rich.SelItalic bar.Buttons(9).MixedState = Rich.SelItalic Case 7 Rich.SelBold = Not Rich.SelBold bar.Buttons(7).MixedState = Rich.SelBold Case 10 SendMessage Rich.hwnd, EM_UNDO, 0, 0 Case 12 Rich.SelAlignment = 0 Case 13 Rich.SelAlignment = 2 Case 14 Rich.SelAlignment = 1 Case 15 Rich.SelAlignment = 1 Case 19 SearchStr = InputBox("Search String", "Roboprint", SearchStr) SearchString Case 16 Rich.SetFocus SendKeys "^c" ' Case 17 Rich.SetFocus SendKeys "^x" Case 18 Rich.SetFocus SendKeys "^v" Case 20 Unload Me End Select End Sub Private Sub fontnames_Click() On Error Resume Next Rich.SelFontName = FontNames.Text Rich.SetFocus End Sub Private Sub Command4_Click() RoboFileOpen Me.hwnd End Sub Private Sub FontSizes_Click() On Error Resume Next Rich.SelFontSize = Val(FontSizes) Rich.SetFocus End Sub Private Sub Form_KeyPress(KeyAscii As Integer) If KeyCode = F3 Then SearchString End Sub Private Sub Form_Load() Dim i As Integer, Sizes As Integer On Error Resume Next For i = 0 To Printer.FontCount FontNames.AddItem Printer.Fonts(i) Next i Sizes = 8 For i = 0 To 4 FontSizes.AddItem Str$(Sizes) Sizes = Sizes + 1 Next i Sizes = Sizes + 1 For i = 5 To 12 FontSizes.AddItem Str$(Sizes) Sizes = Sizes + 2 Next i FontSizes.AddItem 36 FontSizes.AddItem 48 FontSizes.AddItem 72 SendMessage Rich.hwnd, EM_SETMODIFY, False, 0 RPFileName = App.Path + "\" + "Roboprint.rtf" Rich.LoadFile RPFileName End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) Dim Res As Integer Changed = SendMessage(Rich.hwnd, EM_GETMODIFY, 0, 0) If Changed Then Res = MsgBox("Save the changes in " + RPFileName, vbYesNoCancel) If Res = 6 Then Rich.SaveFile RPFileName If Res = 2 Then Cancel = True End If End Sub Private Sub Form_Resize() On Error Resume Next Rich.Left = 600 Rich.Top = bar.Top + bar.Height + 600 Rich.Width = Width - 708 Rich.Height = Height - (Rich.Top + 900) Rich.RightMargin = Rich.Width - 700 End Sub Private Sub Rich_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = 114 Then SearchString End Sub Private Sub Rich_SelChange() On Error Resume Next FontNames.Text = Rich.SelFontName FontSizes.Text = Str$(Rich.SelFontSize) bar.Buttons(7).MixedState = Rich.SelBold bar.Buttons(8).MixedState = Rich.SelUnderline bar.Buttons(9).MixedState = Rich.SelItalic End Sub Private Sub SearchString() Dim seleste As Integer If Rich.SelStart > 0 Then seleste = 1 seleste = Rich.Find(SearchStr, Rich.SelStart + seleste) If seleste = -1 Then MsgBox "Search Text is not Found", , "Robocx" Rich.SelStart = 0 End If Rich.SetFocus End Sub